package com.wmm.fast.main.shop2Observer.eventBus;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: wangzun
 * @Date: 2018/9/13 11:13
 * @Description: 事件处理类,负责添加事件 ,以及通知
 */
public class EventHandler {
    private List<Event> events;

    public EventHandler() {
        events = new ArrayList<>();
    }

    public void addEvent(Object bean,String methodName,Object... args) {
        events.add(new Event(bean, methodName, args));
    }

    public void notifyE() throws Exception {
        for (Event event : events) {
            event.invoke();
        }
    }
}
